//
//  ViewController.m
//  DoctorOnline
//
//  Created by leergou on 16/7/5.
//  Copyright © 2016年 WhiteHouse. All rights reserved.
//

#import "ViewController.h"
#import "NetworkTool.h"
#import "NetworkDefine.h"

@interface ViewController ()



@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self test12];
    
}
#pragma mark - 15.测试15
-(void)test15{
    
    //    请求地址: http://iosapi.itcast.cn/doctorList.json.php
    //    请求参数:{"user_id":1000089,"page_size":15,"page":1}
    
    NSString *urlString = kDoctorListUrl;
    NSDictionary *paramDic = @{
                               @"user_id":@"1000089",
                               @"page_size":@15,
                               @"page":@1
                               };
    
    [self loadURL:urlString params:paramDic];
    
    //    error = Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
    
    //    少了 php
}

#pragma mark - 14.测试14
-(void)test14{
    //    请求地址: http://iosapi.itcast.cn/deleteDoctor.json.php
    //    请求参数:{"user_id":1000089,"doctor_id":300000315}
    
    NSString *urlString = kDeleteDoctorUrl;
    NSDictionary *paramDic = @{
                               @"user_id":@"1000089",
                               @"doctor_id":@300000315
                               };
    
    [self loadURL:urlString params:paramDic];
}

#pragma mark - 13.测试13
-(void)test13{
    
    NSString *urlString = kAddDoctorUrl;
    NSDictionary *paramDic = @{
                               @"user_id":@"1000089",
                               @"doctor_id":@300000315
                               };
    
    [self loadURL:urlString params:paramDic];
}

#pragma mark - 12.测试12

-(void)test12{
    
    //#define kBDWeather_KEY @"17IvzuqmKrK1cGwNL6VQebF9"
    //#define kGetWeather_URL(city) ([NSString stringWithFormat: @"http://api.map.baidu.com/telematics/v3/weather?location=%@&output=json&ak=%@", city, kBDWeather_KEY])
    
    NSString *city = @"上海";
    NSString *url = @"http://api.map.baidu.com/telematics/v3/weather";
    
    NSDictionary *paramDic = @{@"location":city,
                               @"output":@"json",
                               @"ak":@"17IvzuqmKrK1cGwNL6VQebF9"
                               };
    
    [[NetworkTool shareManager] GET_RequestWithUrlString:url parmas:paramDic successBloock:^(id responseObject) {
        
        NSLog(@"天气= %@",responseObject);
    } failureBlock:^(NSError *error) {
        
        NSLog(@"天气错误= %@",error);
    }];
}

#pragma mark - 11.测试11
-(void)test11{
    
    //请求地址: http://iosapi.itcast.cn/doctorReceivingSetting.json.php
    //    请求参数:{"doctor_id":300000315}
    
    NSString *urlString = kDoctorDuties;
    NSDictionary *paramDic = @{
                               @"doctor_id":@300000315
                               };
    
    [self loadURL:urlString params:paramDic];
}

#pragma mark - 10.测试10
-(void)test10{
    
    //请求地址: http://iosapi.itcast.cn/doctorReceivingSetting.json.php
    //    请求参数:{"doctor_id":300000315}
    
    NSString *urlString = kGetIntroductionUrl;
    NSDictionary *paramDic = @{
                               @"doctor_id":@300000315
                               };
    
    [self loadURL:urlString params:paramDic];
}

#pragma mark - 9.测试9
-(void)test9{
    
    //请求地址: http://iosapi.itcast.cn/doctorReceivingSetting.json.php
    //    请求参数:{"doctor_id":300000315}
    
    NSString *urlString = kDoctorReceivingSetting;
    NSDictionary *paramDic = @{
                               @"doctor_id":@300000315
                               };
    
    [self loadURL:urlString params:paramDic];
}


#pragma mark - 8.测试8
-(void)test8{
    
    //   doctor_id 医生编号
    //    请求地址: http://iosapi.itcast.cn/getDoctorInfo.json.php
    //    请求参数:{"user_id":1000089,"doctor_id":300000315}
    
    NSString *urlString = kGetDoctorInfoUrl;
    NSDictionary *paramDic = @{@"user_id":@1000089,
                               @"doctor_id":@300000315 //@200000094
                               };
    
    [self loadURL:urlString params:paramDic];
}


#pragma mark - 7.测试7
- (void)test7{
    
    // {"ci1_id":1,"ci2_id":3,"ci3_id":3,"diagnosis_type":0,"page_size":15,"is_confirmed":1,"user_id":1000089, "page":1,"has_diagnosis":2}
    
    NSString *urlString = kMatchDoctors;
    
    NSDictionary *paramDic = @{@"ci1_id":@1,@"ci2_id":@3,@"ci3_id":@3,@"diagnosis_type":@0,@"page_size":@15,@"is_confirmed":@1,@"user_id":@1000089,@"page":@1,@"has_diagnosis":@2};
    
    [self loadURL:urlString params:paramDic];
}



#pragma mark - 6.测试6
- (void)test6{
    
    // {"page":1,"page_size":15,"ci2_id":3}
    
    NSString *urlString = kComplicationListUrl;
    
    NSDictionary *paramDic = @{@"page":@1,@"page_size":@15,@"ci2_id":@3};
    
    [self loadURL:urlString params:paramDic];
}


#pragma mark - 5.测试5
- (void)test5{
    
    // {"ci1_id":1,"ci2_id":3,"ci3_id":3,"diagnosis_type":0,"is_confirmed":1,"user_id":1000089, "has_diagnosis":2}
    
    NSString *urlString = kMatchedDoctorCountUrl;
    
    NSDictionary *paramDic = @{@"ci1_id":@1,@"ci2_id":@3,@"ci3_id":@3,@"diagnosis_type":@0,@"is_confirmed":@1,@"user_id":@1000089,@"has_diagnosis":@2};

    [self loadURL:urlString params:paramDic];
}

#pragma mark - 4.测试4
- (void)test4{
    
    // 请求参数:{"page":1,"page_size":15,"ci1_id":1,"keyword":""}
    
    NSString *urlString = kSearchCI3Url;
    
    NSDictionary *paramDic = @{@"page":@1,@"page_size":@15,@"ci1_id":@1,@"keyword":@""};
    
    [self loadURL:urlString params:paramDic];
}

#pragma mark - 2.测试2
- (void)test2{
    
    NSString *urlString = kBannersUrl;
    
    NSDictionary *paramDic =
  @{@"login_token":@"985c96ce43bb5ef69de3e1ad8afaa83f",
      @"page_size":@10,
           @"page":@1};
    
    [self loadURL:urlString params:paramDic];
}


#pragma mark - 1.测试1
- (void)test1{
    
    // 请求参数:{"login_token":"985c96ce43bb5ef69de3e1ad8afaa83f"}
    // 登录成功后，用户id为：1000089
    NSString *urlString = kLoginUrl;
    
    NSDictionary *paramDic = @{@"login_token":@"985c96ce43bb5ef69de3e1ad8afaa83f"};
 
    [self loadURL:urlString params:paramDic];
}


#pragma mark - 0.最后统一测试的接口
- (void)loadURL:(NSString *)urlString
         params:(NSDictionary *)paramDic{
    
    [[NetworkTool shareManager] POST_RequestWithUrlString:urlString parmas:paramDic successBloock:^(id responseObject) {
        
        NSLog(@"responseObject = %@",responseObject);
    } failureBlock:^(NSError *error) {
        
        NSLog(@"error = %@",error);
    }];
}


@end
